package com.itcast.eureka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * 1、介绍springboot+eureka实现微服务解决方案（服务器集群管理解决方案）
 * 2、介绍 eureka与springboot的整合思路及应用场景
 * 3、介绍feign与springboot整合的应用场景
 * 4、演示springboot+eureka+dataserver+dataclient整合后，两台集群服务器中，宕机一台服务器，客户端仍可正常访问效果
 *
 */
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public class DemoEurekaClientDataclientApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoEurekaClientDataclientApplication.class, args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate(new OkHttp3ClientHttpRequestFactory());
    }

}
